{include file="../application/admin/view/header.html" /}
<link rel="stylesheet" type="text/css" href="/static/css/uploadify.css">
</head>
<body>

<div class="container">
	<div class="col-md-12">
		<div class="alert kesn_prompt"></div>
	</div>
	<div class="row">
	<button class="btn btn-info" data-toggle="modal" data-target="#create_resource">新增<span class="fui-plus btn-tip"></span></button>

	<form class="navbar-form navbar-right" action="index" role="search"  method="get">
	  <div class="form-group">
	    <div class="input-group input-group-rounded">
	      <input class="form-control" id="keyword" name="keyword" type="search" placeholder="请输入资料名">
	      <span class="input-group-btn">
	        <button type="submit" class="btn kesn_search"><span class="fui-search"></span></button>
	      </span>
	    </div>
	  </div>
	</form>


	<!-- Large modal -->
	<div class="modal fade" id="create_resource" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
	  <div class="modal-dialog modal-lg" role="document">
	    <div class="modal-content">
	       <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	        <h6 class="modal-title" id="gridSystemModalLabel">新增资料</h6>
	      </div>


	      <div class="modal-body">
	  
			  <div class="form-group">
			    <label for="resource_name">资料名</label>
			    <input type="text" class="form-control" id="resource_name" placeholder="">
			  </div>
			
	      <div id="fileQueue"></div>
			<input type="file" name="resource_file" id="uploadify" multiple="true"/>
			<p>
			    <a href="javascript:$('#uploadify').uploadify('upload','*');">上传</a>| 
			    <a href="javascript:$('#uploadify').uploadify('cancel');">取消上传</a>
			</p>
	      </div>
	    </div>
	  </div>
	</div>
	</div><br/>
	&nbsp;&nbsp;<br/>
	<div></div>

	<div class="row">
		<table class="table table-hover">
			<thead>
				<th>ID</th>
				<th>资料</th>
				<th>操作</th>
			</thead>
			<tbody>
			{volist name="resource_list" id="resource"}
			<tr class="_item">
					<th scrope="row">{$resource.id}</th>
					<td>{$resource.resource}</td>
					<td><div>
					<a href="#" class="btn btn-primary kesn_to" data-title="编辑资料" data-id="edit_resource" data-url='/index.php/admin/resource/edit_resource?resource_id={$resource.id}'>编辑<span class="fui-new btn-tip"></span></a>
						<a href="#" class="btn btn-danger del_resource" data-_id="{$resource.id}" data-_name="{$resource.resource}">删除<span class="fui-cross btn-tip"></span></a>
					</div></td>
			</tr>
			{/volist}
		</tbody>
		{$page}
	</div>
</div>
<footer>
	<script type="text/javascript" src="/static/js/vendor/jquery.min.js"></script><!-- 
	<script type="text/javascript" src="/static/js/bootstrap.js"></script> -->
	<script type="text/javascript" src="/static/js/flat-ui.js"></script>
	<script type="text/javascript" src="/static/js/admin.js"></script>
	<script type="text/javascript" src="/static/js/jquery.uploadify.js"></script>
	<script type="text/javascript">
$(document).ready(function(){
    $("#uploadify").uploadify({
    	'buttonText':'选择上传资料',
    	'swf'     : '/static/swf/uploadify.swf',
        'uploader': 'upload_file',
        'fileObjName' : 'resource_file',
        'cancelImg': '/static/img/uploadify-cancel.png',
        'queueID': 'fileQueue',
        'auto': false,
        'multi': true,
        'method' : 'get', 
        'removeCompleted' : true,
        'onUploadStart' : function(file) {
        	var resource_name = $('input#resource_name').val();
        	resource_name = encodeURI(resource_name);
            $("#uploadify").uploadify("settings", "formData", {'resource_name' : resource_name});
        },
         'onUploadSuccess' :function(file,data,res){
         	console.log(data);
         	data = JSON.parse(data);
         	if (data.err != '0') {
         		kesn_prompt('fail',data.content);
         	}else{
         		$("#create_resource").modal('hide');
         		kesn_prompt('success',data.content);
         		window.location.reload();
         	}
         }

    });

    //删除
    $('tbody').on('click','.del_resource',function(){
    	var _this = $(this);
    	var _id = _this.attr('data-_id');
    	var _name = _this.attr('data-_name');
    	var message = '你确定要删除'+_id+': '+_name+'吗？'
    	var _url = 'del_resource';
    	kesn_del(_id,_url,message,_this);
    });
});  
</script>
</footer>
</body>
</html>















































